
//
// 120407 - AH - (Midtun) Created.
//

package org.soekrat.server.serialization;

import java.io.Serializable;

/**
 * <p>
 *   Describes a rat (data) base.
 * </p>
 * @author Arne Halvorsen (AH)
 * @author Laetitia Le Chatton (LLC)
 */
public final class RatDataBaseSerializable implements Serializable 
{
  private static final long serialVersionUID=-2601200065267975313L;

  private Long ratBaseId=null;
  
  private String name=null;
  
  /**
   * <p>
   *   Constructor.
   * </p>
   */
  public RatDataBaseSerializable(){}
  
  /**
   * <p>
   *   Gets id of rat base.
   * </p>
   * @return Id or {@code -1} if not sat.
   */
  public long ratBaseId(){ return ratBaseId==null ? -1 : ratBaseId; }
  
  /**
   * <p>
   *   Sets id of rat base.
   * </p>
   * @param id Id.
   * @return {@code this}.
   */
  public RatDataBaseSerializable ratBaseId(long id)
  {
    if (id<0)
    {
      throw new IllegalArgumentException("id<0 : "+id);
    }
    
    this.ratBaseId=id;
    return this;
  }
  
  /**
   * <p>
   *   Gets name on rat base.
   * </p>
   * @return Name or {@code null} if not sat.
   */
  public String name(){ return this.name; }
  
  /**
   * <p>
   *   Sets the name of the rat base.
   * </p>
   * @param name Name.
   * @return {@code this}.
   */
  public RatDataBaseSerializable name(String name)
  {
    if (name==null)
    {
      throw new NullPointerException("name");
    }
    
    this.name=name;
    return this;
  }
  
  @Override
  public String toString()
  {
    StringBuilder sb=new StringBuilder();
    sb.append("ratBaseId=").append(ratBaseId()).append(", name=").append(name);
    return super.toString();
  }
  
}
